package com.yljk.homedoctor.view.ui;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.graphics.Typeface;
import android.os.Bundle;
import android.os.Handler;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.core.widget.NestedScrollView;

import com.alibaba.android.arouter.core.LogisticsCenter;
import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.android.material.tabs.TabLayout;
import com.shicheng.alerts.AlertDialogManager;
import com.shicheng.alerts.callback.AlertDialogCallback;
import com.yilijk.base.base.BaseFragment;
import com.yilijk.base.constants.UserInfo;
import com.yilijk.base.network.RequestParams;
import com.yilijk.base.network.config.BaseConfig;
import com.yilijk.base.network.https.HttpCallBack;
import com.yilijk.base.utils.ClickUtils;
import com.yilijk.base.utils.LoadingUtils;
import com.yilijk.base.utils.SharedPreferencesUtils;
import com.yilijk.base.utils.ToastUtils;
import com.yljk.homedoctor.HomePopWindowManager;
import com.yljk.homedoctor.HomeUtils;
import com.yljk.homedoctor.R;
import com.yljk.homedoctor.databinding.HomeFragmentDataBinding;
import com.yljk.homedoctor.model.entity.DoctorTirmEntity;
import com.yljk.homedoctor.model.entity.HomeDoctorDetailEntity;
import com.yljk.homedoctor.viewmodel.HomeViewModel;
import com.yljk.homedoctor.viewmodel.listener.PopWindowListenter;
import com.yilijk.base.network.https.HttpUtils;
import com.yilijk.base.utils.CommonUtils;
import com.yilijk.base.utils.DevicesUtils;
import com.yljk.homedoctor.model.entity.QrcodeBindingEntity;
import com.yljk.homedoctor.model.entity.QrcodeGetEntity;
;
import com.yljk.homedoctor.model.entity.live.LiveTabBean;
import com.yljk.homedoctor.view.view.NoticeView;
import com.yljk.homedoctor.view.view.PersonalTaxDialog;
import com.yljk.servicemanager.constants.ClickApi;
import com.yljk.servicemanager.constants.ConfigApi;
import com.yljk.servicemanager.constants.ReactApi;
import com.yljk.servicemanager.constants.RouterApi;
import com.yljk.servicemanager.constants.UrlApi;
import com.youth.banner.listener.OnBannerListener;
import com.zzhoujay.richtext.RichText;

import java.util.Timer;
import java.util.TimerTask;

import static android.app.Activity.RESULT_OK;
import static android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
import static com.yljk.servicemanager.constants.RouterApi.QrCodeActivity;


@Route(path = RouterApi.HOME_FRAGMENT)
public class Home_Fragment extends BaseFragment<HomeViewModel, HomeFragmentDataBinding> {
    public static final int REQUEST_FOR_SCAN = 101;
    private final float topScrollYFloat = 200.0f;
    //是否第一次加载数据\
    private boolean isFirstLoading = true;
    private Handler handler = new Handler();
    @Override
    public void onResume() {
//        dialogChain = DialogChain.create(1)
//                .addInterceptor(new IntimacyDialog(getContext()))
//                .addInterceptor(new WisdomDialog(getContext()))
//                .build();
//        dialogChain.process();
        ClickUtils.sendEvent(ClickApi.Home.Home_Load, getActivity(), "首页载入");
        binding.notice.start();
        //医生基本信息
        if (isFirstLoading) {
            isFirstLoading = false;
            LoadingUtils.getLoadingUtils(getContext()).showLoading();
        }
        //        //协议更新
        mViewModel.checkPreserveAgreement();
        mViewModel.getData();
        mViewModel.getLiveTabList();
        super.onResume();

    }

    @Override
    public void onPause() {
        binding.notice.pause();
        super.onPause();
    }

    @Override
    public void onStop() {
        binding.notice.pause();
        super.onStop();
    }

    @Override
    public void onDestroy() {
        RichText.clear(this);
        if (personalTaxDialog != null && personalTaxDialog.isShowing()) {
            personalTaxDialog.dismiss();
        }
        super.onDestroy();
    }



    /**
     * 弹窗初始化
     */
    private void initPopWindow() {
        //出示二维码
        initShowScanPop();
        //新版弹窗
        initNewUserPop();
        //医生确认信息
        showInfohint();
        //药品分享
        shareDrugPop();
        //温馨提示
        initSignPop();
        //通知弹窗
        initPersonalTax();
        //会议弹窗
        initMeetingPop();
    }

    PopupWindow meetingPop;
    View meetingPopView;
    TextView meetingCentent;
    TextView meetingCancel;
    TextView meetingSure;
    TextView meetingTitle;

    private void initMeetingPop() {
        meetingPop = new PopupWindow();
        meetingPopView = LayoutInflater.from(getContext()).inflate(R.layout.popwindow_sign, null);
        meetingCentent = (TextView) meetingPopView.findViewById(R.id.sign_centent);
        meetingCancel = (TextView) meetingPopView.findViewById(R.id.sign_cancel);
        meetingSure = (TextView) meetingPopView.findViewById(R.id.sign_sure);
        meetingTitle = (TextView) meetingPopView.findViewById(R.id.sign_title);
        meetingPop.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
        meetingPop.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);
        meetingPop.setContentView(meetingPopView);
        meetingPop.setOutsideTouchable(false);
        meetingPop.setFocusable(false);
        meetingPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                setBackgroundAlpha(1.0f);
            }
        });
        meetingCentent.setText("请您先签署讲者协议！");
        meetingTitle.setText("签署提示");
        meetingCancel.setText("取消");
        meetingSure.setText("去签署");
        ClickUtils.setFastOnClickListener(meetingCancel, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                meetingPop.dismiss();
            }
        });
        ClickUtils.setFastOnClickListener(meetingSure, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mViewModel.getMeetingContentBean() != null && mViewModel.getMeetingContentBean().getId() != 0) {
                    HomeUtils.toJumeMeetProtocal(mViewModel.getMeetingContentBean().getId());
                    meetingPop.dismiss();
                }
            }
        });


    }

    /**
     * 个税通知弹窗
     */
    private PersonalTaxDialog.Builder personalTaxDialogBuilder;
    private PersonalTaxDialog personalTaxDialog;

    private void initPersonalTax() {
        personalTaxDialogBuilder = new PersonalTaxDialog.Builder(getContext());
        personalTaxDialogBuilder.setPositiveButton("去看看", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                ARouter.getInstance().build(RouterApi.WebActivity).withBoolean("isPersonalTax", true).navigation();
                personalTaxDialog.dismiss();
            }
        });
        personalTaxDialogBuilder.setTitle("通知");
        personalTaxDialogBuilder.setMessage("尊敬的医生，您好：\n感谢您的信任和入驻慧医天下平台，我们将会与第三方合作，为您提供相应的结算、税务申报及税收筹划等服务。在此情况下，需要经您同意，并授权慧医天下向第三方提供部分必要个人信息，详见第三方服务协议。");
        personalTaxDialog = personalTaxDialogBuilder.create();
        personalTaxDialog.setCancelable(false);
    }



    /**
     * 医生确认信息关闭
     */
    void doctorConfirmClose(int i) {
        mViewModel.updataIsNoProcess(i);

    }

    /**
     * 客户端提醒
     */




    /**
     * 医生首页基本信息刷新
     */

    private int localPreliminaryStatus;
    private int localPracticeStatus;
    private boolean isFirstAzUseNew;

    /**
     * 出示二维码弹窗
     */
    private ImageView scanLayoutImageView;   //二维码图片
    private TextView scanLayoutContent;      //二维码文案
    private ImageView scanLayoutClose;       //关闭事件
    private View showScanPopView;            //二维码视图View
    private PopupWindow showScanPop;

    //出示二维码弹窗
    void initShowScanPop() {
        showScanPop = new PopupWindow();
        showScanPop.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
        showScanPop.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);
        showScanPopView = LayoutInflater.from(getContext()).inflate(R.layout.scan_layout, null);
        scanLayoutImageView = (ImageView) showScanPopView.findViewById(R.id.scan_layout_imageView);
        scanLayoutContent = (TextView) showScanPopView.findViewById(R.id.scan_layout_content);
        scanLayoutClose = (ImageView) showScanPopView.findViewById(R.id.scan_layout_close);
        showScanPop.setContentView(showScanPopView);
        showScanPop.setFocusable(false);
        showScanPop.setOutsideTouchable(false);
        showScanPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                setBackgroundAlpha(1.0f);
            }
        });
    }

    /***
     * 新版注册弹窗
     *
     */
    private PopupWindow newUserPop;
    private View newUserPopView;
    private TextView newUserPopTitle;
    private TextView newUserPopResult;
    private TextView newUserPopCause;
    private TextView newUserPopDetail;

    private Button newUserPopBt;
    private ImageView newUserPopClose;
    private ImageView newUserPopImg;

    // 新版注册弹窗
    void initNewUserPop() {
        newUserPop = new PopupWindow();
        newUserPopView = LayoutInflater.from(getContext()).inflate(R.layout.new_user_pop, null);
        newUserPopTitle = (TextView) newUserPopView.findViewById(R.id.new_user_pop_title);
        newUserPopResult = (TextView) newUserPopView.findViewById(R.id.new_user_pop_result);
        newUserPopCause = (TextView) newUserPopView.findViewById(R.id.new_user_pop_cause);
        newUserPopDetail = (TextView) newUserPopView.findViewById(R.id.new_user_pop_detail);
        newUserPopBt = (Button) newUserPopView.findViewById(R.id.new_user_pop_bt);
        newUserPopClose = (ImageView) newUserPopView.findViewById(R.id.new_user_pop_close);
        Glide.with(getContext()).load(R.mipmap.new_user_pop_close).into(newUserPopClose);
        newUserPopImg = (ImageView) newUserPopView.findViewById(R.id.new_user_pop_img);

        newUserPop.setContentView(newUserPopView);
        newUserPop.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
        newUserPop.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);
        //点击外部弹出不消失
        newUserPop.setFocusable(false);
        newUserPop.setOutsideTouchable(false);

        newUserPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                setBackgroundAlpha(1.0f);
                SharedPreferencesUtils.getInstance().savePop(UserInfo.isFirstAzUseNew + mViewModel.getDoctorDetail().getMobile(), false);
            }
        });
    }

    /**
     * 新版弹窗show
     */
    void initNewUserPopShow() {
        //存取状态
        localPreliminaryStatus = SharedPreferencesUtils.getInstance().getPop_Integer(UserInfo.preliminartStatus + mViewModel.getDoctorDetail().getMobile(), 0);//本地初审状态
        localPracticeStatus = SharedPreferencesUtils.getInstance().getPop_Integer(UserInfo.practiceStatus + mViewModel.getDoctorDetail().getMobile(), 0);//本地执业资格认证状态
        isFirstAzUseNew = SharedPreferencesUtils.getInstance().getPop_Boolean(UserInfo.isFirstAzUseNew + mViewModel.getDoctorDetail().getMobile(), true);
        HomeDoctorDetailEntity.DataBean doctorDetailInfo = mViewModel.getDoctorDetail();
        if (localPreliminaryStatus != doctorDetailInfo.getPreliminaryStatus() || localPracticeStatus != doctorDetailInfo.getPracticeStatus() || isFirstAzUseNew) {
//            if (doctorDetailInfo.isAzUseNew() && (doctorDetailInfo.getTitleName() != null && !doctorDetailInfo.getTitleName().equals("住院医师")) || (doctorDetailInfo.getTitleName() != null && !doctorDetailInfo.getTitleName().equals("医士"))) {
            if (getActivity() != null && doctorDetailInfo.getTitleName() != null || doctorDetailInfo.getTitleName() != null) {// && !doctorDetailInfo.getTitleName().equals("住院医师")) // && !doctorDetailInfo.getTitleName().equals("医士")
                newUserPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
                CommonUtils.setBackgroundAlpha(newUserPop, getActivity(), 0.3f);
            }
            SharedPreferencesUtils.getInstance().savePop(UserInfo.preliminartStatus + doctorDetailInfo.getMobile(), doctorDetailInfo.getPreliminaryStatus());
            SharedPreferencesUtils.getInstance().savePop(UserInfo.practiceStatus + doctorDetailInfo.getMobile(), doctorDetailInfo.getPracticeStatus());
        }
    }

    /**
     * 医生确认信息弹窗
     */
    private PopupWindow infoHintPop;
    private View infoHintPopView;
    private TextView inithintCause;
    private TextView inithintInfo;
    private TextView inithintTitle;
    private Button inithintBt;
    private ImageView closeInfoPop;

    //医生确认信息弹窗
    void showInfohint() {
        infoHintPop = new PopupWindow();
        infoHintPopView = LayoutInflater.from(getActivity()).inflate(R.layout.info_hint, null);
        inithintCause = (TextView) infoHintPopView.findViewById(R.id.inithint_cause);
        inithintInfo = (TextView) infoHintPopView.findViewById(R.id.inithint_info);
        inithintTitle = (TextView) infoHintPopView.findViewById(R.id.inithint_title);
        inithintBt = (Button) infoHintPopView.findViewById(R.id.inithint_bt);
        closeInfoPop = (ImageView) infoHintPopView.findViewById(R.id.close_infoPop);
        Glide.with(getContext()).load(R.mipmap.infohint_close).into(closeInfoPop);
        infoHintPop.setContentView(infoHintPopView);
        infoHintPop.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
        infoHintPop.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);
        //点击外部弹出不消失
        infoHintPop.setFocusable(false);
        infoHintPop.setOutsideTouchable(false);

        infoHintPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                setBackgroundAlpha(1.0f);
            }
        });

    }


    /**
     * 分享药品弹窗
     */
    private PopupWindow shareDrugPop;
    private View shareDrugPopView;
    private RelativeLayout shareImg;
    private RelativeLayout shareImg1;
    private ImageView shareImage;
    private TextView shareToFriends;
    private TextView saveLocal;
    private ImageView shareDrugClose;
    private boolean platformAuditStatus = false;
    //分享药品弹窗
    void shareDrugPop() {
        shareDrugPop = new PopupWindow();
        shareDrugPopView = LayoutInflater.from(getContext()).inflate(R.layout.share_drug_pop, null);
        shareImg = (RelativeLayout) shareDrugPopView.findViewById(R.id.shareImg);
        shareImg1 = (RelativeLayout) shareDrugPopView.findViewById(R.id.shareImg1);
        shareImage = (ImageView) shareDrugPopView.findViewById(R.id.share_image);
//        shareDrugImg = (ImageView) shareDrugPopView.findViewById(R.id.share_drugImg);
//        shareDrugName = (TextView) shareDrugPopView.findViewById(R.id.share_drugName);
//        shareDoctorName = (TextView) shareDrugPopView.findViewById(R.id.share_doctorName);
//        shareScan = (ImageView) shareDrugPopView.findViewById(R.id.share_scan);
        shareToFriends = (TextView) shareDrugPopView.findViewById(R.id.share_to_friends);
        saveLocal = (TextView) shareDrugPopView.findViewById(R.id.save_local);
        shareDrugClose = (ImageView) shareDrugPopView.findViewById(R.id.share_drugClose);
        shareDrugPop.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
        shareDrugPop.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);
        shareDrugPop.setContentView(shareDrugPopView);
        shareDrugPop.setOutsideTouchable(false);
        shareDrugPop.setFocusable(false);
        shareDrugPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                setBackgroundAlpha(1.0f);
            }
        });
    }

    /**
     * 温馨提示
     */
    private TextView signCentent;
    private TextView signCancel;
    private TextView signSure;
    private TextView signTitle;
    private PopupWindow signPop;
    private View signView;

    //温馨提示
    private void initSignPop() {
        signPop = new PopupWindow();
        signView = LayoutInflater.from(getContext()).inflate(R.layout.popwindow_sign, null);
        signCentent = (TextView) signView.findViewById(R.id.sign_centent);
        signCancel = (TextView) signView.findViewById(R.id.sign_cancel);
        signSure = (TextView) signView.findViewById(R.id.sign_sure);
        signTitle = (TextView) signView.findViewById(R.id.sign_title);
        signPop.setWidth(LinearLayout.LayoutParams.MATCH_PARENT);
        signPop.setHeight(LinearLayout.LayoutParams.MATCH_PARENT);
        signPop.setContentView(signView);
        signPop.setOutsideTouchable(false);
        signPop.setFocusable(false);
        signPop.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                setBackgroundAlpha(1.0f);
            }
        });
        //sign去认证
        ClickUtils.setFastOnClickListener(signSure, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mViewModel.toAuthe();
            }

        });
        //取消
        ClickUtils.setFastOnClickListener(signCancel, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                signPop.dismiss();
            }
        });
    }
    /**
     * pop蒙版
     */
    private void setBackgroundAlpha(float v) {
        if (getActivity() == null) return;
        Window window = getActivity().getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        window.setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND);
        lp.alpha = v; //0.0-1.0
        window.setAttributes(lp);
    }

    private Dialog matchDialog = null;
    private int count = 5;
    private boolean isMatchCanClick = false;
    private Timer timer = null;
    private TimerTask timerTask = null;

    @Override
    public void onActivityResult(int requestCode, int resultCode, @Nullable @org.jetbrains.annotations.Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == REQUEST_FOR_SCAN) {
            if (resultCode == RESULT_OK && data != null) {
                int resultType = data.getIntExtra("result_type", 0);
                String resultString = data.getStringExtra("result_string");
                if (resultType == 1 && !TextUtils.isEmpty(resultString)) {
                    String qrcodeId = resultString.replace("qrcodeId=", "");
                    RequestParams jsonObject = new RequestParams();
                    jsonObject.put("bindQrCodeId", qrcodeId);
                    HttpUtils.get(UrlApi.qrcodeGet, jsonObject, new HttpCallBack<QrcodeGetEntity>() {
                        @Override
                        public void onSuccess(QrcodeGetEntity getEntity, int code) {
                            if (code == 200 && "200".equals(getEntity.getStatus()) && getEntity.getData() != null) {
                                if (!"astrazeneca".equals(getEntity.getData().getChannel())) {
                                    qrCodeBinding(qrcodeId, true, false);
                                } else {
                                    count = 5;
                                    isMatchCanClick = false;
                                    View view = LayoutInflater.from(getContext()).inflate(R.layout.match_confirm, null);
                                    TextView titleTv = view.findViewById(R.id.tv_title);
                                    TextView doctorNameTv = view.findViewById(R.id.tv_doctor_name);
                                    TextView doctorTitleTv = view.findViewById(R.id.tv_doctor_title);
                                    TextView doctorHospitalTv = view.findViewById(R.id.tv_doctor_hospital);
                                    TextView subTimeTv = view.findViewById(R.id.tv_sub_time);
                                    String titleOrgTv = "医生您好，我是阿斯利康的" +
                                            getEntity.getData().getSalesRepName() +
                                            "，工号" +
                                            getEntity.getData().getSalesRepId() +
                                            "，希望成为您的助手";
                                    SpannableString spannableString = new SpannableString(titleOrgTv);
                                    StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);
                                    spannableString.setSpan(styleSpan, 12, 12 + getEntity.getData().getSalesRepName().length(), SPAN_EXCLUSIVE_EXCLUSIVE);
                                    titleTv.setText(spannableString);
//                                    titleTv.setText("医生您好: ");
                                    doctorNameTv.setText(getEntity.getData().getDoctorName());
                                    doctorTitleTv.setText(getEntity.getData().getDoctorTitle());
                                    doctorHospitalTv.setText(getEntity.getData().getDoctorHospitalName() + getEntity.getData().getDoctorDepartment());
                                    ForegroundColorSpan colorSpan = new ForegroundColorSpan(getResources().getColor(R.color.red));
                                    timer = new Timer();
                                    timerTask = new TimerTask() {
                                        @Override
                                        public void run() {
                                            if (count > 1) {
                                                handler.post(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        SpannableString spStr = new SpannableString("请仔细确认以上信息，" + count + "秒后按钮可点击");
                                                        spStr.setSpan(colorSpan, 10, 11, SPAN_EXCLUSIVE_EXCLUSIVE);
                                                        subTimeTv.setText(spStr);
                                                    }
                                                });
                                                count--;
                                                isMatchCanClick = false;
                                            } else {
                                                isMatchCanClick = true;
                                                handler.post(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        subTimeTv.setVisibility(View.GONE);
                                                    }
                                                });
                                                timerTask.cancel();
                                                timer.cancel();
                                            }
                                        }
                                    };
                                    timer.schedule(timerTask, 0, 1000);

                                    view.findViewById(R.id.tv_submit).setOnClickListener(new View.OnClickListener() {
                                        @Override
                                        public void onClick(View v) {
                                            if (!isMatchCanClick) {
                                                return;
                                            }
                                            qrCodeBinding(qrcodeId, true, true);
                                            matchDialog.dismiss();
                                        }
                                    });
                                    view.findViewById(R.id.tv_not_me).setOnClickListener(new View.OnClickListener() {
                                        @Override
                                        public void onClick(View v) {
                                            if (!isMatchCanClick) {
                                                return;
                                            }
                                            qrCodeBinding(qrcodeId, false, true);
                                            matchDialog.dismiss();
                                        }
                                    });
                                    matchDialog = new AlertDialog.Builder(getActivity(), R.style.TransparentDialog)
                                            .setOnDismissListener(new DialogInterface.OnDismissListener() {
                                                @Override
                                                public void onDismiss(DialogInterface dialog) {
                                                    if (timerTask != null) {
                                                        timerTask.cancel();
                                                    }
                                                    if (timer != null) {
                                                        timer.cancel();
                                                    }
                                                }
                                            }).setView(view).setCancelable(false).show();

                                }
                            } else {
                                Toast.makeText(getContext(), getEntity.getMessage(), Toast.LENGTH_SHORT).show();
                            }
                        }

                        @Override
                        public void onFailure(String failureMsg, int statusCode) {
                        }
                    });


                }

            }
        }
    }

    AlertDialog confirmDialog;

    private void qrCodeBinding(String qrcodeId, boolean binded, boolean isAZ) {
        HomeDoctorDetailEntity.DataBean doctorDetailInfo = mViewModel.getDoctorDetail();
        RequestParams jsonObject = new RequestParams();
        jsonObject.put("bindQrCodeId", qrcodeId);
        jsonObject.put("binded", binded);
        HttpUtils.post(UrlApi.qrcodeBinding, jsonObject, new HttpCallBack<QrcodeBindingEntity>() {
            @Override
            public void onSuccess(QrcodeBindingEntity bindingEntity, int code) {
                if (code == 200 && "200".equals(bindingEntity.getStatus())) {
                    if (!isAZ) {
                        String okText = doctorDetailInfo.getPreliminaryStatus() != 0 || doctorDetailInfo.getPracticeStatus() != 0 ? "我知道了" : "去注册";

                        View view = LayoutInflater.from(getContext()).inflate(R.layout.confirm_dialog, null);
                        TextView btnTV = view.findViewById(R.id.tv_btn);
                        btnTV.setText(okText);
                        btnTV.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                if (confirmDialog != null) {
                                    confirmDialog.dismiss();
                                }
                                if (doctorDetailInfo.getPreliminaryStatus() != 0 || doctorDetailInfo.getPracticeStatus() != 0) {
                                    return;
                                }
                                if (doctorDetailInfo.getPreliminaryStatus() == 0) {
                                    mViewModel.toPreliminary();
                                } else {
                                    mViewModel.toPractice();
                                }
                            }
                        });
                        confirmDialog = new AlertDialog.Builder(getContext(), R.style.TransparentDialog)
                                .setCancelable(false)
                                .setView(view)
                                .show();
                    } else {
                        if (binded) {
                            Toast.makeText(getContext(), "绑定成功！", Toast.LENGTH_SHORT).show();
                        } else {
                            Toast.makeText(getContext(), "绑定失败！", Toast.LENGTH_SHORT).show();
                        }
                    }
                    mViewModel.getData();
                } else {
                    Toast.makeText(getContext(), bindingEntity.getMessage(), Toast.LENGTH_SHORT).show();

                }
            }

            @Override
            public void onFailure(String failureMsg, int statusCode) {
                ToastUtils.showShort(failureMsg);
            }
        });
    }


    /**
     * 医生工作室协议弹窗
     */
    void alertStudio() {
        AlertDialogManager.builder()
                .setContext(getContext())
                .setType(3)
                .setTitle("创建医生工作室提醒")
                .setContent("\t\t\t\t尊敬的医生您好，平台已为您提供医生工作室功能，创建您的工作室后，平台将为您分配医生作为助手，协助您处理日常工作，您可以前往了解更多的医生工作室信息。")
                .setBottomItemCallback(new AlertDialogCallback() {
                    @Override
                    public void ERROR() {
                        //关闭
                        AlertDialogManager.dismiss();
                    }

                    @Override
                    public void ERROR(String s) {

                    }

                    @Override
                    public void ERROR(int i, String s) {

                    }

                    @Override
                    public void Success() {
                        //去看看
                        AlertDialogManager.dismiss();
                        String url = HttpUtils.getH5Url() +
//                        String url = "http://192.168.5.141:8080/"+
                                "/index.html?t=" + System.currentTimeMillis() + "#" +
                                "/doctor-create-studio?tk=" +
                                DevicesUtils.getToken();
                        ARouter.getInstance().build("/WebActivity/WebActivity")
                                .withString("title", "我的工作室")
                                .withString("url", url)
                                .withBoolean("ishtml", false)
                                .navigation();
                    }

                    @Override
                    public void Success(String s) {

                    }

                    @Override
                    public void Success(int i, String s) {

                    }
                })
                .show();
    }

    @Override
    protected int getContentViewId() {
        return R.layout.home_fragment;
    }

    @Override
    protected void processLogic(Bundle bundle) {
        initPopWindow();
        HomePopWindowManager.getInstance().init(getActivity());
        //默认不可点击
        binding.toCertificate.setEnabled(false);
        PopWindowListenter popWindowListenter = new PopWindowListenter() {
            @Override
            public void individual() {
                if (!personalTaxDialog.isShowing()) {
                    personalTaxDialog.show();
                }
            }

            @Override
            public void supplementary(HomeDoctorDetailEntity.DataBean doctorDetailInfo) {
                //弹出补充提示
                newUserPopTitle.setText("补充证件信息");
                newUserPopImg.setVisibility(View.GONE);
                newUserPopResult.setText("需要补充证件信息，仅用于医生审核");
                newUserPopCause.setText("原因：" + doctorDetailInfo.getPlatformAuditReason());
                newUserPopBt.setVisibility(View.VISIBLE);
                newUserPopBt.setText("去补充");
                if (platformAuditStatus && getContext() != null) {
                    newUserPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
                    CommonUtils.setBackgroundAlpha(newUserPop, getActivity(), 0.3f);
                    platformAuditStatus = false;
                }
            }

            @Override
            public void certification(HomeDoctorDetailEntity.DataBean doctorDetailInfo) {
                newUserPopTitle.setText("认证结果提示");
                if (doctorDetailInfo.getPracticeStatus() == 0) {
                    newUserPopTitle.setText("验证结果提示");
                    binding.certificationTo.setText("去认证");
                    binding.certificationTo.setTextColor(getResources().getColor(R.color.newTheme));

                    newUserPopBt.setVisibility(View.GONE);
                    newUserPopResult.setText("恭喜您通过实名验证");
                    newUserPopCause.setText("患者可通过扫码关注您。");
                    newUserPopDetail.setText("");
                    initNewUserPopShow();
                    return;
                } else if (doctorDetailInfo.getPracticeStatus() == 1) {
                    binding.certificationTo.setText("认证中");
                    binding.certificationTo.setTextColor(getActivity().getResources().getColor(R.color.newTheme));
                    return;
                } else if (doctorDetailInfo.getPracticeStatus() == 2) {
                    binding.certificationTo.setText("认证成功");
                    binding.certificationTo.setTextColor(getActivity().getResources().getColor(R.color.color_0CBF89));
                    binding.authentication.setVisibility(View.GONE);
                    binding.isPassCertification.setVisibility(View.VISIBLE);
                    if (doctorDetailInfo.isBzShow()) {
                        binding.isPassCertification.setImageBitmap(BitmapFactory.decodeResource(getActivity().getResources(), R.mipmap.authentication_finish_bz));
                    } else {
                        binding.isPassCertification.setImageBitmap(BitmapFactory.decodeResource(getActivity().getResources(), R.mipmap.authentication_finish));
                    }

                    if (doctorDetailInfo.getTumorHasCharging()) {
                        newUserPopBt.setVisibility(View.VISIBLE);
                        newUserPopResult.setText("恭喜您，多点执业认证通过。");
                        newUserPopCause.setText("已为您开放【在线问诊】等所有功能权限，赶快邀请患者在线复诊吧！");
                        newUserPopDetail.setText("");
                        newUserPopBt.setText("开启在线问诊");
                        initNewUserPopShow();
                    }
                } else if (doctorDetailInfo.getPracticeStatus() == 3) {
                    binding.certificationTo.setText("认证失败，去修改");
                    binding.certificationTo.setTextColor(getActivity().getResources().getColor(R.color.color_FFA604));
                    newUserPopBt.setVisibility(View.VISIBLE);
                    newUserPopResult.setText("多点执业认证不通过");
                    newUserPopCause.setText(doctorDetailInfo.getAuditRemark());
                    newUserPopDetail.setText("您也可以将补充资料发送至邮箱：yszc@yiliyili.com.cn,我们将尽快为您处理，谢谢！");
                    newUserPopBt.setText("去修改");
                    initNewUserPopShow();
                    return;
                }
            }

            @Override
            public void information(DoctorTirmEntity.DataBean data) {
                inithintCause.setText(data.getTips());
                String[] s = data.getPracticeReceiveDate().split(" ");
                String[] s1 = data.getCertReceiveDate().split(" ");
                inithintInfo.setText("以下为您提交多点执业的认证信息，请仔细核对\n" +
                        "姓名：" + data.getName() + "\n" +
                        "性别：" + data.getGenderName() + "\n" +
                        "身份证号：" + data.getIdCardNo() + "\n" +
                        "手机号码：" + data.getMobile() + "\n" +
                        "执业证书编码：" + data.getPracticeNo() + "\n" +
                        "执业证发证日期：" + s[0] + "\n" +
                        "第一执业机构：" + data.getHospitalName() + "\n" +
                        "执业类别：" + data.getPracticeType() + "\n" +
                        "执业范围：" + data.getPracScopeApproval() + "\n" +
                        "一级科室：" + data.getParentDepartmentName() + "\n" +
                        "二级科室：" + data.getDepartmentName() + "\n" +
                        "职称：" + data.getTitleName() + "\n" +
                        "擅长专业：" + data.getAdvantage() + "\n" +
                        "个人简介：" + data.getDescription() + "\n" +
                        "资格证书编码：" + data.getDoctorNo() + "\n" +
                        "资格证发证日期：" + s1[0] + "\n");
                if (getContext() != null) {
                    infoHintPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
                    CommonUtils.setBackgroundAlpha(infoHintPop, getActivity(), 0.3f);
                }
            }

            @Override
            public void doctorSudio() {
                alertStudio();
            }

            @Override
            public void signPopShow() {
                mViewModel.signPopShow();
            }

            @Override
            public void showScan(String url,String time) {
                Glide.with(getContext()).load(url).into(scanLayoutImageView);
                scanLayoutContent.setText("用微信扫一扫上面的二维码图案，享受咨询开药服务(二维码将于" + time + "更新)");
                showScanPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
                CommonUtils.setBackgroundAlpha(showScanPop, getActivity(), 0.3f);
            }

            @Override
            public void realNameAuthentication() {
                //未实名验证
                signCentent.setText("请先进行实名验证！");
                signSure.setText("去实名验证");
                signPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
                CommonUtils.setBackgroundAlpha(signPop, getActivity(), 0.3f);
            }

            @Override
            public void multipoint() {
                signCentent.setText("请先进行多点执业认证！");
                signSure.setText("去多点执业认证");
                signPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
                CommonUtils.setBackgroundAlpha(signPop, getActivity(), 0.3f);
            }

            @Override
            public void auditPass() {
                signCentent.setText("您的资料已审核通过，正在为您备案中，烦请您耐心等待！");
                signSure.setText("知道了");
                signPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
                CommonUtils.setBackgroundAlpha(signPop, getActivity(), 0.3f);
            }

            @Override
            public void infoHintDismiss() {
                infoHintPop.dismiss();
            }

            @Override
            public void signPopdismiss() {
                signPop.dismiss();
            }

            @Override
            public void newUserPopDismiss() {
                newUserPop.dismiss();
            }

            @Override
            public void showDrugShare(String data) {
                Glide.with(getContext()).load(data).into(shareImage);
                shareDrugPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
                CommonUtils.setBackgroundAlpha(shareDrugPop, getActivity(), 0.3f);
            }

            @Override
            public void toNewUserPopShow(int practiceStatus,String audit) {
                newUserPopTitle.setText("认证结果提示");
                if (practiceStatus == 0){
                    newUserPopBt.setVisibility(View.GONE);
                    newUserPopResult.setText("恭喜您通过实名验证");
                    newUserPopCause.setText("患者可通过扫码关注您。");
                    newUserPopDetail.setText("");
                }else if (practiceStatus == 2){
                    newUserPopBt.setVisibility(View.VISIBLE);
                    newUserPopResult.setText("恭喜您，多点执业认证通过。");
                    newUserPopCause.setText("已为您开放【在线问诊】等所有功能权限，赶快邀请患者在线复诊吧！");
                    newUserPopDetail.setText("");
                    newUserPopBt.setText("开启在线问诊");
                }else if (practiceStatus == 3){
                    newUserPopBt.setVisibility(View.VISIBLE);
                    newUserPopResult.setText("多点执业认证不通过");
                    newUserPopCause.setText(audit);
                    newUserPopDetail.setText("您也可以将补充资料发送至邮箱：yszc@yiliyili.com.cn,我们将尽快为您处理，谢谢！");
                    newUserPopBt.setText("去修改");
                }
                initNewUserPopShow();
            }
        };
        mViewModel.setBinding(getContext(),binding,popWindowListenter);
        mViewModel.initDailogAndPop();
        mViewModel.getHealthData();
        mViewModel.initView();
    }

    @Override
    protected void setListener() {
        //开通问诊
        ClickUtils.setFastOnClickListener(binding.guideDoctorBt, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mViewModel.toOpenInquiry();
            }
        });
        ClickUtils.setFastOnClickListener(binding.homeAvatar, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent changeTabIntent = new Intent(BaseConfig.Receiver.BroadcastReceiver);
                changeTabIntent.putExtra(ConfigApi.changeTab, true);         //向广播接收器传递数据
                changeTabIntent.putExtra(ConfigApi.tabIndex, 3);         //向广播接收器传递数据
                if (getActivity() != null) {
                    getActivity().sendBroadcast(changeTabIntent);      //发送广播
                }
            }
        });
        ClickUtils.setAdapterItemFastOnClickListener(mViewModel.liveAdapter, new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                mViewModel.liveDetail(position);
            }
        });
        binding.liveTab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                ClickUtils.sendEvent(ClickApi.Home.Home_LiveTab, getActivity(), "直播tab切换点击");
                mViewModel.getLiveList(tab.getPosition());
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });

        //立即查看、立即参会
        ClickUtils.setFastOnClickListener(binding.homeFragmentMeetingLook, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ClickUtils.sendEvent(ClickApi.Home.Home_MeetDetail, getActivity(), "会议详情点击");
                LiveTabBean.DataBean.MeetingBean meetingContentBean = mViewModel.getMeetingContentBean();
                if (meetingContentBean != null) {
                    if (meetingContentBean.getScene_type() == 202 || meetingContentBean.getScene_type() == 203) {
                        HomeUtils.toJumpMeeting(meetingContentBean.getId());
                    } else {
                        if (meetingContentBean.getLive_status() == 51 &&
                                meetingContentBean.getScene_type() == 201 &&
                                meetingContentBean.getIs_need_sign() == 1 &&
                                meetingContentBean.getLive_status() != 99 &&
                                meetingContentBean.getIs_sign() == 0) {
                            //弹窗
                            if (getActivity() != null) {
                                meetingPop.showAtLocation(getActivity().getWindow().getDecorView(), Gravity.CENTER, 0, 0);
                                CommonUtils.setBackgroundAlpha(meetingPop, getActivity(), 0.3f);
                            }
                        } else {
                            if (meetingContentBean.getLive_status() == 51) {
                                HomeUtils.toJumpMeetcreate(meetingContentBean.getId());
                            } else if (meetingContentBean.getLive_status() == 50) {
                                HomeUtils.toJumpMeeting(meetingContentBean.getId());
                            } else {
                                HomeUtils.toJumpMeeting(meetingContentBean.getId());
                            }
                        }
                    }


//                    if (meetingContentBean.getIs_need_sign() == 1 && meetingContentBean.getIs_sign() == 0)  {
//
//                    } else {
//
//                    }
                }
            }
        });

        //更多会议
        ClickUtils.setFastOnClickListener(binding.homeFragmentMeetingMore, view -> {
            ClickUtils.sendEvent(ClickApi.Home.Home_MeetMore, getActivity(), "会议更多点击");
            HomeUtils.toJumeMeetList();
        });

        //讲者协议
        ClickUtils.setFastOnClickListener(binding.homeFragmentMeetingCopy, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ClickUtils.sendEvent(ClickApi.Home.Home_MeetCopy, getActivity(), "会议地址复制点击");
                LiveTabBean.DataBean.MeetingBean meetingContentBean = mViewModel.getMeetingContentBean();
                if (meetingContentBean != null && meetingContentBean.getScene_type() == 201) {
                    if (meetingContentBean.getId() != 0) {
                        HomeUtils.toJumeMeetProtocal(meetingContentBean.getId());
                    }
                } else {
                    if (meetingContentBean != null && meetingContentBean.getMeeting_url() != null && getActivity() != null) {
                        ClipboardManager clipboardManager = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                        ClipData clipData = ClipData.newPlainText("message", meetingContentBean.getMeeting_url());
                        clipboardManager.setPrimaryClip(clipData);
                        Toast.makeText(getActivity(), "会议地址复制成功，请在电脑端浏览器中开哦～", Toast.LENGTH_SHORT).show();
                    }
                }


            }
        });

        HomePopWindowManager.getInstance().setliveSureClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                moveToAppointmentLiveDetail();
            }
        });

        //信息点击
        ClickUtils.setFastOnClickListener(binding.homefragmentPersionInfo, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mViewModel.toAvator();
            }
        });
        //服务患者
        ClickUtils.setFastOnClickListener(binding.homefragmentServerPatientCount, view -> {
                    ClickUtils.sendEvent(ClickApi.Home.Home_Service, getActivity(), "服务患者点击");
                    HomeUtils.push(getContext(), ReactApi.HOME_DOCTORBUNDLE, ReactApi.Home.PatientListPageNew);
                }
        );
        //问诊次数
        ClickUtils.setFastOnClickListener(binding.homeInqurityCount, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                跳转我的问诊
                ClickUtils.sendEvent(ClickApi.Home.Home_Inquiry, getActivity(), "问诊次数点击");
                HomeUtils.push(getContext(), ReactApi.IM_DOCTORBUNDLE, ReactApi.Message.MyPhysicianVisits);
            }
        });
        //患教次数
        ClickUtils.setFastOnClickListener(binding.homefragmentPatientTeachCount, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                跳转我的患教
                ClickUtils.sendEvent(ClickApi.Home.Home_Patient, getActivity(), "患者次数点击");
                HomeUtils.push(getContext(), ReactApi.HOME_DOCTORBUNDLE, ReactApi.Home.MyTaskPage);
            }
        });
        //直播查看更多
        ClickUtils.setFastOnClickListener(binding.liveMore, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ClickUtils.sendEvent(ClickApi.Home.Home_LiveMore, getActivity(), "直播更多点击");
                HomeUtils.toJumeLiveList();
            }
        });
        //我的诊室功能入口点击
        ClickUtils.setAdapterItemFastOnClickListener(mViewModel.myRoomAdapter, new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                mViewModel.myRoomEntry(position);
            }
        });

        binding.homeBanner.setOnBannerListener(new OnBannerListener() {
            @Override
            public void OnBannerClick(int position) {
                mViewModel.toBanner(position);
            }
        });
        //医生确认信息-关闭
        ClickUtils.setFastOnClickListener(closeInfoPop, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //关闭
                doctorConfirmClose(4);
            }
        });
        //医生确认信息-确认
        ClickUtils.setFastOnClickListener(inithintBt, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //确认
                doctorConfirmClose(3);
            }
        });
        //弹窗button
        ClickUtils.setFastOnClickListener(newUserPopBt, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mViewModel.toNewUserBt();
            }
        });
        //补充证件信息
        ClickUtils.setFastOnClickListener(binding.infoStatus, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mViewModel.supplement();
            }
        });
        //新版弹窗关闭
        ClickUtils.setFastOnClickListener(newUserPopClose, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                newUserPop.dismiss();
            }
        });
        //滚动监听
        binding.homeNestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
            @Override
            public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                mViewModel.toScrollChange(scrollY);
            }
        });
        //公告点击
        binding.notice.setOnItemClickListener(new NoticeView.OnItemClickListener() {
            @Override
            public void onItemClick(TextView view, int position) {
                ClickUtils.sendEvent(ClickApi.Home.Home_Notice, getActivity(), "公告点击");
                mViewModel.toNoticeDetail(position);
            }
        });
        //医生指南item点击
        ClickUtils.setAdapterItemFastOnClickListener(mViewModel.doctorGuideAdapter, new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ClickUtils.sendEvent(ClickApi.Home.Home_DoctorGuide, getActivity(), "医生指南点击");
               mViewModel.toGuideDetail(position);
            }
        });
        //常用套餐分享
        ClickUtils.setAdapterItemChildFastOnClickListener(mViewModel.commonAdapter, new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {

                int id = view.getId();
                if (id == R.id.commomShare) {
                    mViewModel.toShare(position);
                }
            }
        });
        //常用套餐点击
        ClickUtils.setAdapterItemFastOnClickListener(mViewModel.commonAdapter, new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ClickUtils.sendEvent(ClickApi.Home.Home_DrugsDetails, getActivity(), "药品详情点击");
                mViewModel.toDrugDetail(position);
            }
        });
        //药品分享关闭
        ClickUtils.setFastOnClickListener(shareDrugClose, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                shareDrugPop.dismiss();
            }
        });
        //分享给好友
        ClickUtils.setFastOnClickListener(shareToFriends, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mViewModel.toShareFriends(shareImg1);
            }
        });
        //保存本地
        ClickUtils.setFastOnClickListener(saveLocal, new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                mViewModel.saveImage(shareImg1);

            }
        });
        //二维码关闭
        ClickUtils.setFastOnClickListener(scanLayoutClose, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                showScanPop.dismiss();
            }
        });

        ClickUtils.setFastOnClickListener(binding.toScan, new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                ClickUtils.sendEvent(ClickApi.Home.Home_Scan, getActivity(), "扫码点击");
//            扫一扫
                Postcard postcard = ARouter.getInstance()
                        .build(QrCodeActivity);
                LogisticsCenter.completion(postcard);
                Intent intent = new Intent(getActivity(), postcard.getDestination());
                intent.putExtras(postcard.getExtras());
                startActivityForResult(intent, REQUEST_FOR_SCAN);

//            ARouter.getInstance().build(RouterApi.QrCodeActivity).navigation(getActivity(), REQUEST_FOR_SCAN);
            }
        });
        //我的随访点击
//        ClickUtils.setFastOnClickListener(followUp, new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                if (doctorDetailInfo.isHomePageCharges() && !doctorDetailInfo.isPrescriptionSupport()) {
//                    HomeUtils.push(getContext(), ReactApi.IM_DOCTORBUNDLE, ReactApi.FollowUp);
//                } else {
//                    signPopShow();
//                }
//            }
//        });

        //实名验证-去认证
        ClickUtils.setFastOnClickListener(binding.toAuthentication, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                HomeUtils.push(getContext(), ReactApi.LOGIN_DOCTORBUNDLE, ReactApi.Login.AutonymApprovePage);
//                if (doctorDetailInfo.isAzUseNew()) {
//                    HomeUtils.push(getContext(), ReactApi.MY_DOCTORBUNDLE, ReactApi.AutonymApprovePageNew);
//                } else {
//                    HomeUtils.push(getContext(), ReactApi.MY_DOCTORBUNDLE, ReactApi.AutonymApprovePage);
//                }
//                if (!doctorDetailInfo.isPrescriptionSupport() && (doctorDetailInfo.getTitleName() != null && !doctorDetailInfo.getTitleName().isEmpty()) && doctorDetailInfo.getTitleName().equals("住院医师")) {
//                    return;
//                }
//                if (doctorDetailInfo.isStrong(ERROR)Channel()) {
//                    if (doctorDetailInfo.isAzUseNew()) {

//                    } else {

//                    }
//                } else {
//                    HomeUtils.push(getContext(), ReactApi.MY_DOCTORBUNDLE, ReactApi.AutonymApprovePage);
//                }
            }
        });
        //多点执业认证-去认证
        ClickUtils.setFastOnClickListener(binding.toCertificate, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               mViewModel.toRZ();
            }
        });
        //问诊设置
        ClickUtils.setFastOnClickListener(binding.inquriySetting, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ClickUtils.sendEvent(ClickApi.Home.Home_Setup, getActivity(), "问诊设置点击");
                mViewModel.toInquirySetting();
            }
        });
        //查看药品清单
        ClickUtils.setFastOnClickListener(binding.toDrugList, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ClickUtils.sendEvent(ClickApi.Home.Home_DrugsMore, getActivity(), "药品更多设置点击");
               mViewModel.toDrugMore();
            }
        });
        //扫一扫
//        ClickUtils.setFastOnClickListener(toScan, new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                ARouter.getInstance().build(RouterApi.QrCodeActivity).navigation();
//            }
//        });
    }

    @Override
    public void onClick(View v) {

    }
}
